const log4js = request('log4js')
log4js.configure({
    appenders: { 
    stdout: {//控制台输出
      type: 'console'
    },
    req: {  //请求转发日志
        type: 'dateFile',    //指定日志文件按时间打印
        filename: 'logs/reqlog/req',  //指定输出文件路径
        pattern: 'yyyy-MM-dd.log',
        alwaysIncludePattern: true
    },
    err: {  //错误日志
        type: 'dateFile',
        filename: 'logs/errlog/err',
        pattern: 'yyyy-MM-dd.log',
        alwaysIncludePattern: true
    },
    oth: {  //其他日志
        type: 'dateFile',
        filename: 'logs/othlog/oth',
        pattern: 'yyyy-MM-dd.log',
        alwaysIncludePattern: true
    }
   },
    categories: { 
      //appenders:采用的appender,取appenders项,level:设置级别
      default: { appenders: ['stdout', 'req'], level: 'debug' },
      err: { appenders: ['stdout', 'err'], level: 'error' },
   }
});

const logger = log4js.getLogger()
const errLog = log4js.getLogger('err')


//请求信息
const infoLogger = (content) =>{
    logger.info(content)
  }
  
//请求信息
const errLogger = (content) =>{
    errLog.error(content);
}

module.exports = {
    infoLogger,
    errLogger
}
  